package com.example.demo.controller;

import com.example.demo.entity.ResponseInfo;
import com.example.demo.utils.JMeterTestUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/jmeter")
@Api(tags = "JMeter测试接口")
@Slf4j
public class JMeterController {

    @Value("${jmeterFilePath}")
    String fileName;

    @PostMapping("/run")
    public ResponseInfo<String> test(){
        log.info("fileName:{}",fileName);
        JMeterTestUtils.JMeterRun(fileName);
        return ResponseInfo.successInfo("");
    }
}
